% This is for the case of t1g1,t2g1,t3g1,tntg1,t1g2,...

function [result] = lead_ntng(panel,tindex,gindex,var,nlead)

    ng=length(unique(panel(:,gindex)));
    nt=length(unique(panel(:,tindex)));
    
    temp=panel(:,var);
    temp=reshape(temp,nt,ng);

    result(1:nt,1:ng)=nan;
    result(1:nt-nlead,:)=temp(nlead+1:nt,:);
    result=result(:);
            


end

